<html>
<head>
<script type='text/javascript'>
function validar_portatiles(formulario) 
{
	if ((formulario.cantpme.value != "1")  && (formulario.cantpme.value != "2") && (formulario.cantpme.value != "0")) 
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpme.focus();
		return (false);
	}
	if ((formulario.cantpdd.value != "1")  && (formulario.cantpdd.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpdd.focus();
		return (false);
	}
	if ((formulario.cantpop.value != "1")   && (formulario.cantpop.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpop.focus();
		return (false);
	}
	if ((formulario.cantpbat.value != "1")   && (formulario.cantpbat.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpbat.focus();
		return (false);
	}
    if ((formulario.cantpadapnb.value != "1")   && (formulario.cantpadapnb.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpadapnb.focus();
		return (false);
	}
}

function validar_escritorio(formulario) 
{
	if ((formulario.cantpme.value != "1")  && (formulario.cantpme.value != "2")  && (formulario.cantpme.value != "3") && (formulario.cantpme.value != "4") 
		&& (formulario.cantpme.value != "5") && (formulario.cantpme.value != "6") && (formulario.cantpme.value != "0")) 
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpme.focus();
		return (false);
	}
	if ((formulario.cantpdd.value != "1")  && (formulario.cantpdd.value != "2" && (formulario.cantpdd.value != "3") && (formulario.cantpdd.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpdd.focus();
		return (false);
	}
	if ((formulario.cantppr.value != "1") && (formulario.cantppr.value != "2") && (formulario.cantppr.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantppr.focus();
		return (false);
	}
	if ((formulario.cantpf.value != "1") && (formulario.cantpf.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpf.focus();
		return (false);
	}	
	if ((formulario.cantpop.value != "1") && (formulario.cantpop.value != "2")  && (formulario.cantpop.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpop.focus();
		return (false);
	}
	if ((formulario.cantpmb.value != "1")   && (formulario.cantpmb.value != "0"))
	{
		alert("Debe Ingresar un Valor Valido");
		formulario.cantpmb.focus();
		return (false);
	}
}


</script>
</head>
<body onload="document.getElementById('cantpme').focus();">

<?php
	require_once "funciones.php";
	$link_caweb = con_caweb();

	$sucursal=$_SESSION['caweb']['sucursal'];
	$interno=$_REQUEST['interno'];
	$result="SELECT * FROM seriales WHERE interno = '$interno'";
	$result=mysql_query($result,$link_caweb) or die('Error seriales, '.mysql_error());
	if(mysql_num_rows($result) > 0)
	{
		$row = mysql_fetch_array($result);
		
		$result25 ="UPDATE consecutivos SET cabeceras=cabeceras+1";
		$result25=mysql_query($result25,$link_caweb) or die('Error consecutivos, '.mysql_error());
		
		$result26 ="SELECT * FROM consecutivos";
		$result26=mysql_query($result26,$link_caweb) or die('Error consecutivos, '.mysql_error());
		$row26 = mysql_fetch_array($result26);
		
		$_SESSION['caweb']['consecutivo'] = $row26[cabeceras];
		$transaccion = $_SESSION['caweb']['consecutivo'];
		
		$item = strtoupper($row[item]);
		if(ereg("NB",$item) OR ereg("NE",$item) OR preg_match("/CATAB/",$item))
		{
			if($row[sucursalcontrol]==$sucursal)
			{
				if($row[bodega]=='ALI' or $row[bodega]=='12')
				{
					if(substr($row[item],0,1) == 'C')
					{
						echo "<form name='bautizar20' method='POST' action='bautizar21.php' onSubmit='return validar_portatiles(this)'>";
							echo "Conteo Inicial de las partes en transaccion ($transaccion)";
							echo "<table border=1><tr bgcolor='aabbcc'><td>Descripcion<td>Cantidad</tr>";
							echo "<tr><td>Memoria (Max 2)<td><input type='text' size='5' name='cantpme' id='cantpme' value='1'></tr>";
							echo "<tr><td>Disco Duros (Max 1)<td><input type='text' size='5' name='cantpdd' id='cantpdd' value='1'></tr>";
							echo "<tr><td>Opticos (Max 1)<td><input type='text' size='5' name='cantpop' id='cantpop' value='1'></tr>";
							echo "<tr><td>Baterias (Max 2)<td><input type='text' size='5' name='cantpbat' id='cantpbat' value='1'></tr>";
							echo "</table>";
							echo "<input type='hidden' name= 'internoactualizar' value='".$interno."' />";
                            echo "<input type='hidden' name= 'itemactualizar' value='".$item."' />";
							echo "<input type='hidden' name= 'tipoequipo' value='Portatil' />";
							echo "<input type='submit' value='Iniciar' />";
						echo "</form>";
					}
					else
					{
						echo "No es Un CAT Portatil, es un $row[item]";
					}
				}
				else
				{
					echo "Interno CAT Portatil Debe Estar en bodega ALI o 12, esta en $row[bodega]";				
				}
			}
			else
			{
				echo "Interno CAT Portatil Debe Estar en sucursal $sucursal";
			}			
		}
		else
		{
			if($row[sucursalcontrol]==$sucursal)
			{
				if($row[bodega]=='ALI' or $row[bodega]=='12')
				{
					if(substr($row[item],0,1) == 'C')
					{
						echo "<form name='bautizar20' method='POST' action='bautizar21.php' onSubmit='return validar_escritorio(this)'>";
							echo "Conteo Inicial de las partes en transaccion ($transaccion)";
							echo "<table border=1><tr bgcolor='aabbcc'><td>Descripcion<td>Cantidad</tr>";
							echo "<tr><td>Memoria (Max 6)<td><input type='text' size='5' name='cantpme' id='cantpme' value='1'></tr>";
							echo "<tr><td>Disco Duros (Max 3)<td><input type='text' size='5' name='cantpdd' id='cantpdd' value='1'></tr>";
							echo "<tr><td>Tarjetas (Max 4)<td><input type='text' size='5' name='cantpt' id='cantpt' value='0'></tr>";
							echo "<tr><td>Procesador (Max 2)<td><input type='text' size='5' name='cantppr' id='cantppr' value='1'></tr>";
							echo "<tr><td>Fuente (Max 2)<td><input type='text' size='5' name='cantpf' id='cantpf' value='1'></tr>";
							echo "<tr><td>Opticos (Max 2)<td><input type='text' size='5' name='cantpop' id='cantpop' value='1'></tr>";
							echo "<tr><td>Main Board (Max 2)<td><input type='text' size='5' name='cantpmb' id='cantpmb' value='1'></tr>";
							echo "</table>";
							echo "<input type='hidden' name= 'internoactualizar' value='".$interno."' />";
                            echo "<input type='hidden' name= 'itemactualizar' value='".$item."' />";
							echo "<input type='hidden' name= 'tipoequipo' value='Escritorio' />";
							echo "<input type='submit' value='Iniciar' />";
						echo "</form>";
					}
					else
					{
						echo "No es Un CAT, es un $row[item]";
					}
				}
				else
				{
					echo "Interno CAT Debe Estar en bodega ALI o 12, esta en $row[bodega]";				
				}
			}
			else
			{
				echo "Interno CAT Debe Estar en sucursal $sucursal";
			}
		}
	}
	else
	{
		echo "Interno '$interno' CAT No Encontrado...";		
	}		

?>

</body>
</html>